package com.itheima.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/demo7")
public class ServletDemo7 extends HttpServlet {
    @Override

    //请求转发:客户端发起请求 服务器A请求服务器B
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //向请求域中存储数据
        req.setAttribute("username", "zhangsan");

        //通过名称获取请求域对象中的数据
        Object username = req.getAttribute("username");

        //通过名称移除请求域对象中的数据
        req.removeAttribute("username");
    }
}
